import tkinter as tk
from PIL import ImageTk
import qrcode

def genQrImage(data):
    img = qrcode.make(data)
    return img

def topQrImage(parent, data):
    img = qrcode.make(data)
    win = tk.Toplevel(parent)
    win.title("QR Code")
    imagetk = ImageTk.PhotoImage(image=img)
    label = tk.Label(win, image=imagetk)
    label.pack(side='left', expand=True)
    win.update()
    win.minsize(win.winfo_width(), win.winfo_height())
    x_cordinate = int((win.winfo_screenwidth() / 2) - (win.winfo_width() / 2))
    y_cordinate = int((win.winfo_screenheight() / 2) - (win.winfo_height() / 2))
    win.geometry("+{}+{}".format(x_cordinate, y_cordinate))
    win.mainloop()
    

if __name__ == '__main__':
    #root = tk.Tk()
    #tk.Button(root, command=lambda:topQrImage(root, "你是一个一个一个一个一个一个一个一个一个一个"), text="TEST").pack()
    #root.mainloop()
    # parseQrImage("bin/qrcode/magisk24.3.png")
    pass
